package top.whq6.study.dao.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import top.whq6.study.dao.CacheInfo;
import top.whq6.study.dao.ClazzDao;
import top.whq6.study.entity.Clazz;

@Slf4j
@Component
public class ClazzDaoImpl implements ClazzDao {

  @Override
  public void addClass(Clazz clz) {
    log.info("Add Class: {}", clz);
    CacheInfo.CLAZZ_CACHE.put(clz.getId(), clz);
  }

  @Override
  public void modClass(Clazz clz) {
    log.info("Modify Class info: {}", clz);
    CacheInfo.CLAZZ_CACHE.put(clz.getId(), clz);
    log.info("Modify Class Success");
  }

  @Override
  public void delClass(int cId) {
    log.info("Delete Class id: {}", cId);
    CacheInfo.CLAZZ_CACHE.remove(cId);
    log.info("Delete Class Success");
  }
}
